
<?php

$dirlist = explode('/',$_SERVER['PHP_SELF']);
$document_root = $_SERVER['DOCUMENT_ROOT'];
require "$document_root/$dirlist[1]/conf/conf.php";

$connMng = new ConnManger($db_conf,$mem_conf);
$connstep = $connMng->getConn_step();

$record = "normal";
$verify = "match";
$passwd = "same";
$mode = $_POST['mode'];
if ($mode == "reset") {

    $id = $_POST['id'];
    $oldpasswd = $_POST['oldpasswd'];
    $newpasswd = $_POST['newpasswd'];
    $newpasswdc = $_POST['newpasswdc'];

    
    
    $get_mem_list = Step_admin_user_DAO::getRecord($id,$connstep);
    
    if ($get_mem_list == null) {
        $record = "unfound";
    }else {
        $oldpasswdd = $get_mem_list->getPassword();
        if($oldpasswd !== $oldpasswdd) {
            $passwd = "different";
        }elseif($newpasswd !== $newpasswdc ) {
                $verify = "unmatch";
        }else {
            $get_mem_list->setPassword($newpasswd);
            Step_admin_user_DAO::update($connMng,$connStep);
        }
    }
    
    
}
?>

<?php
$page_groupId = GROUP_USER_MNG;
$page_pageId = PAGE_CHANGE_PASSWD;
require "$document_root/$dirList[1]/mng/view/framepages/moudle_base.php";
?>
<html>
<body>
<h3>密码修改</h3><br />
<form method = 'post' action="">
    <table>
        <tr><td>请输入用户名</td><td><input type="text" name="id" value="<?php echo $id ?>" /></td></tr>
        <tr><td>请输入旧密码</td><td><input type="text" name="oldpasswd" value="<?php echo $oldpasswd ?>"/></td></tr>
        <tr><td>请输入新密码</td><td><input type="text" name="newpasswd" value="<?php echo $newpasswd ?>"/></td>
        <tr><td>确认新密码</td><td><input type="text" name="newpasswdc" value="<?php echo $newpasswdc ?>"></td></tr>
    </table>
    <input type="submit" value="提交">
    <input type="hidden" name="mode" value="reset">
</form>


<script src="../lib/bootstrap/js/bootstrap.js"></script>
<script>
    function init() {
        var record ="<?php echo $record ?>";
        if (record == "unfound") {
            alert("用户不存在");
        }
        var verify = "<?php echo $verify ?>";
        if (verify == "unmatch") {
            alert("新密码不一致，请确认输入");
        }
        var passwd = "<?php echo $passwd ?>"
        if (passwd == "different") {
            alert("旧密码不正确");
        }

    }
</script>
</body>
</html>

